#include "task.h"
#include "hardware/hardware.h"
#include "gui/gui.h"
#include "web/web.h"
#include "CountDown.h"

//任务句柄
TaskHandle_t Task_GUI;
TaskHandle_t Task_Pressure;
TaskHandle_t Task_Quality;
TaskHandle_t Task_MOTOR;
TaskHandle_t Task_WEB;
TaskHandle_t Task_Wifi;
TaskHandle_t Task_Flow;
TaskHandle_t Task_Web;
TaskHandle_t Task_Battery;
TaskHandle_t Task_Led;
TimerHandle_t xTimer_count_down;

void my_tasks_init(void)
{
  //lvgl任务
  xTaskCreatePinnedToCore(
  gui_task,   
  "gui_task",      
  4096,        
  NULL,         
  1,          
  &Task_GUI,   
  0             
  );
    
  //创建电机任务
  xTaskCreatePinnedToCore(
  motor_task,   
  "motor_task", 
  2048,       
  NULL,        
  2,            
  &Task_MOTOR, 
  1            
  );

  //创建压力采集任务
  xTaskCreatePinnedToCore(
  pressure_task,    
  "pression_task", 
  1024,       
  NULL,        
  1,           
  &Task_Pressure,  
  1       
  );

  //创建质量采集任务
  xTaskCreatePinnedToCore(
  quality_task,    
  "quality_task", 
  1024,       
  NULL,        
  1,           
  &Task_Quality,  
  1             
  );

  //创建web任务
  xTaskCreatePinnedToCore(
  web_task,    
  "web_task", 
  2048,       
  NULL,        
  2,           
  &Task_Web,  
  1             
  );

  //创建wifi任务
  xTaskCreatePinnedToCore(
  wifi_task,    
  "wifi_task", 
  1024,       
  NULL,        
  1,           
  &Task_Wifi,  
  1             
  );

  //创建电池任务
  xTaskCreatePinnedToCore(
  battery_task,    
  "battery_task", 
  1024,       
  NULL,        
  1,           
  &Task_Battery,  
  1             
  );

  //创建倒计时任务
  xTimer_count_down = xTimerCreate
  (
      "countDown",    
      pdMS_TO_TICKS(1000),
      pdTRUE,                  
      (void*) 1,           
      vTimerCallback        
  );
  xTimerStart(xTimer_count_down, 0 );
}

